'use strict';

function compute_median(collection) {
  //在这里写入代码
  let arr= collection.sort(function(a, b) {
    return a - b;
  });
  
  if(arr.length%2===0)
  {
    return (parseInt(arr[arr.length/2])+parseInt( arr[(arr.length/2)-1]))/2;
  }
  else
  {
    return parseInt( arr[(arr.length-1)/2]);

  }
  return arr;
}


module.exports = compute_median;


